<?php


namespace app\admin\controller;


use app\admin\logic\AdminLogic;
use app\common\library\TokenManager;
use app\common\validate\AdminValidate;
use think\Request;

class PublicController extends BaseController
{
    /**
     * 登陆
     * @route('admin/login')
     */
    public function login(Request $request)
    {
        $form = $request->only(['username', 'password', 'nickname'], 'post');
        $form = [
            'username'=>'as',
            'password'=>'4sadasd56',
        ];
        $valid = $this->validate($form, AdminValidate::class, 'login');

        if ($valid !== true) {
            return $this->error($valid);
        }
        $data = $this->model->where('username', $username)->find();
        if (!$data) {
            return 'NO_EXIST_USER';
        }
        if (!$data->verifyPassword($password)) {
            return 'USER_PASS_ERROR';
        }


        (new TokenManager())->create('we');
    }

}
